/*******************************************************************************
 * Copyright (c) 2010 Sylvain Sicard.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Contributors:
 *     Sylvain Sicard - initial API and implementation
 ******************************************************************************/
package com.googlecode.ssdutils.beanconverter.test.testcases;

import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.googlecode.ssdutils.beanconverter.test.entities.AddresseA;
import com.googlecode.ssdutils.beanconverter.test.entities.CompanieA;
import com.googlecode.ssdutils.beanconverter.test.entities.PeopleA;
import com.googlecode.ssdutils.beanconverter.test.entities.PeopleB;
import com.googlecode.ssdutils.beanconverter.test.entities.PeopleC;


/**
 * @author Sylvain Sicard
 * 
 */
public class Main {
	static PeopleA p1A = null;

	public static void setUp() {

		p1A = new PeopleA();
		p1A.setName("Sylvain");
		p1A.setAge(28);
		p1A.setRate(5);
		p1A.setByteField("sylvain as byte".getBytes());
		p1A.setObjectArray(new Object[] { new Object() });
		Map<String, String> map_ = new HashMap<String, String>();
		map_.put("a", "b");
		p1A.setMap_(map_);
		Collection<String> collection_ = new LinkedList<String>();
		collection_.add("c");
		p1A.setCollection_(collection_);

		AddresseA a1A = new AddresseA();
		a1A.setStreet("my street");
		p1A.setAddresse(a1A);

		AddresseA a2A = new AddresseA();
		a2A.setStreet("my street 2");
		CompanieA c1A = new CompanieA();
		c1A.setAddresse(a2A);
		c1A.setName("companie name");
		p1A.setCompanie(c1A);
	}

	public static void main(String[] args) {
		setUp();

		final ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext();
		applicationContext
				.setConfigLocations(new String[] { "classpath:application-context.xml" });
		applicationContext.refresh();

		final ConvertionTest test = (ConvertionTest) applicationContext
				.getBean("convertionTest");
		PeopleB p1B = test.testConverter(p1A);
		PeopleC p1C = test.testConverter(p1B);
		System.out.println("p1A : " + p1A);
		System.out.println("p1B : " + p1B);
		System.out.println("p1C : " + p1C);
	}

}
